<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<div>123</div>
	<p>234</p>
	<script type="text/javascript">
		var div = document.getElementsByTagName('div')[0];
		var p = document.getElementsByTagName('p')[0];
		function addEvent (elem,type,handle) {
			if(elem.addEventListener) {
				elem.addEventListener(type,handle,false);
			}else if(elem.attachEvent) {
				elem.attachEvent('on' + type,function () {
					handle.call(elem);
				});
			}else {
				elem['on'+ type] = handle; 
			}
		}
	</script>
</body>
</html>